<?php namespace App\Http\Traits;

trait AdminResponse
{

    /**
     * @param $message
     * @param string  $url
     * @return \Illuminate\Http\JsonResponse
     * return success info
     */
    protected function success($message, $url='')
    {
        return $this->toJsonData($message, 1, $url);
    }

    /**
     * @param $message
     * @param string  $url
     * @return \Illuminate\Http\JsonResponse
     * return error info
     */
    protected function error($message, $url='')
    {
        return $this->toJsonData($message, 0, $url);
    }



    /**
     * @param $message
     * @param $status
     * @param string  $url
     * @return \Illuminate\Http\JsonResponse
     */
    private function toJsonData($message, $status, $url='')
    {
        $data['status'] = $status;
        $data['message'] = $message;
        $data['url'] = $url;
        return response()->json($data);
    }
}
